<?php

if(!defined('_HTML_OPTIONS_')) {
define('_HTML_OPTIONS_', 1);

function itstock_html_options($type, $name, $field = '',  &$data = null, $edit = false, &$struct = null, $id = 'id', $extra = false) {
  if(is_null($struct)) {
    itstock_structure($struct, $type);
  }
  if(!$edit){
    echo '<option disabled selected value="">Chose one.</option>';
  }
  if (itstock_search_all($struct))
    foreach ($struct['data'] as $options) {
    printf('<option %s value="%s" %s>%s</option>', ($extra?'data-'.$extra.'='.$options[$extra]:''),itstock_encode($options[$id]), ((!is_null($data) && $edit && $data['data'][0][$field] === $options[$id]) ? 'selected' : ''), $options[$name]);
  }
  echo $struct['msg'];
  
}

}
?>
